package com.leyou.item.web;

import com.leyou.common.vo.ResponseResult;
import com.leyou.item.pojo.SpecGroup;
import com.leyou.item.pojo.SpecParam;
import com.leyou.item.service.SpecificationService;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/spec")
public class SpecificationController {

    @Autowired
    SpecificationService specificationService;

    @GetMapping("/group/{cid}")
    public ResponseEntity<ResponseResult<List<SpecGroup>>> querySpecGroups(@PathVariable int cid) {
        List<SpecGroup> list = specificationService.querySpecGroups(cid);
        return ResponseEntity.ok(ResponseResult.success(list));
    }

    @GetMapping("/params/{gid}")
    public ResponseEntity<ResponseResult<List<SpecParam>>> querySpecParams(@PathVariable int gid) {
        List<SpecParam> list = specificationService.querySpecParams(gid);
        return ResponseEntity.ok(ResponseResult.success(list));
    }
}
